//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing.Diagram
{
    internal class ElementPropertySet : IOfficeXmlSerializable
    {
        internal const string xmlName = "prSet";
        private bool? coherent3DOff;
        private string csTypeId;
        private int? custAng;
        private bool? custFlipHor;
        private bool? custFlipVert;
        private int? custLinFactNeighborX;
        private int? custLinFactNeighborY;
        private int? custLinFactX;
        private int? custLinFactY;
        private int? custRadScaleInc;
        private int? custRadScaleRad;
        private int? custScaleX;
        private int? custScaleY;
        private int? custSzX;
        private int? custSzY;
        private bool? custT;
        private string loCatId;
        private string loTypeId;
        private bool? phldr;
        private string phldrT;
        private string presAssocID;
        private LayoutVariablePropertySet presLayoutVars;
        private string presName;
        private int? presStyleCnt;
        private int? presStyleIdx;
        private string presStyleLbl;
        private string qsTypeId;
        private ShapeStyle style;

        #region IOfficeXmlSerializable Members

        public void ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read(xmlName))
            {
                presAssocID = c.GetOptionalString("presAssocID");
                presName = c.GetOptionalString("presName");
                presStyleLbl = c.GetOptionalString("presStyleLbl");
                presStyleIdx = c.GetOptionalInteger("presStyleIdx");
                presStyleCnt = c.GetOptionalInteger("presStyleCnt");
                loTypeId = c.GetOptionalString("loTypeId");
                loCatId = c.GetOptionalString("loCatId");
                qsTypeId = c.GetOptionalString("qsTypeId");
                csTypeId = c.GetOptionalString("csTypeId");
                coherent3DOff = c.GetOptionalBoolean("coherent3DOff");
                phldrT = c.GetOptionalString("phldrT");
                phldr = c.GetOptionalBoolean("phldr");
                custAng = c.GetOptionalInteger("custAng");
                custFlipVert = c.GetOptionalBoolean("custFlipVert");
                custFlipHor = c.GetOptionalBoolean("custFlipHor");
                custSzX = c.GetOptionalInteger("custSzX");
                custSzY = c.GetOptionalInteger("custSzY");
                custScaleX = c.GetOptionalInteger("custScaleX");
                custScaleY = c.GetOptionalInteger("custScaleY");
                custT = c.GetOptionalBoolean("custT");
                custLinFactX = c.GetOptionalInteger("custLinFactX");
                custLinFactY = c.GetOptionalInteger("custLinFactY");
                custLinFactNeighborX = c.GetOptionalInteger("custLinFactNeighborX");
                custLinFactNeighborY = c.GetOptionalInteger("custLinFactNeighborY");
                custRadScaleRad = c.GetOptionalInteger("custRadScaleRad");
                custRadScaleInc = c.GetOptionalInteger("custRadScaleInc");
                presLayoutVars = c.ReadOptionalElementAs<LayoutVariablePropertySet>("presLayoutVars");
                style = c.ReadOptionalElement<ShapeStyle>("style");
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write(xmlName))
            {
                c.SetOptionalString("presAssocID", presAssocID);
                c.SetOptionalString("presName", presName);
                c.SetOptionalString("presStyleLbl", presStyleLbl);
                c.SetOptionalInteger("presStyleIdx", presStyleIdx);
                c.SetOptionalInteger("presStyleCnt", presStyleCnt);
                c.SetOptionalString("loTypeId", loTypeId);
                c.SetOptionalString("loCatId", loCatId);
                c.SetOptionalString("qsTypeId", qsTypeId);
                c.SetOptionalString("csTypeId", csTypeId);
                c.SetOptionalBoolean("coherent3DOff", coherent3DOff);
                c.SetOptionalString("phldrT", phldrT);
                c.SetOptionalBoolean("phldr", phldr);
                c.SetOptionalInteger("custAng", custAng);
                c.SetOptionalBoolean("custFlipVert", custFlipVert);
                c.SetOptionalBoolean("custFlipHor", custFlipHor);
                c.SetOptionalInteger("custSzX", custSzX);
                c.SetOptionalInteger("custSzY", custSzY);
                c.SetOptionalInteger("custScaleX", custScaleX);
                c.SetOptionalInteger("custScaleY", custScaleY);
                c.SetOptionalBoolean("custT", custT);
                c.SetOptionalInteger("custLinFactX", custLinFactX);
                c.SetOptionalInteger("custLinFactY", custLinFactY);
                c.SetOptionalInteger("custLinFactNeighborX", custLinFactNeighborX);
                c.SetOptionalInteger("custLinFactNeighborY", custLinFactNeighborY);
                c.SetOptionalInteger("custRadScaleRad", custRadScaleRad);
                c.SetOptionalInteger("custRadScaleInc", custRadScaleInc);
                c.WriteOptionalElementAs(presLayoutVars, "presLayoutVars");
                c.WriteOptionalElement(style);
            }
        }

        #endregion
    }
}